using LiJ.Common.Core;
using LiJ.Http.Mos;
using LiJ.Framework.OAuth.Mos;
using System.Threading.Tasks;

namespace LiJ.Framework.OAuth
{
	/// <inheritdoc />
	/// <summary>
	///  小程序用户相关接口
	/// </summary>
	public class WxAppUserApi : WxOauthBaseApi
	{
		public WxAppUserApi(AppConfig config)
			: base(config)
		{
		}

		/// <summary>
		///   获取会话code接口
		/// </summary>
		/// <param name="jsCode"></param>
		/// <returns></returns>
		public async Task<WxGetSessionCodeResp> GetSessionCodeAsync(string jsCode)
		{
		    var lHttpRequest = new LHttpRequest
		    {
		        HttpMothed = HttpMothed.Get,
		        AddressUrl = "https://api.weixin.qq.com" +
		                     string.Format(
		                         "/sns/jscode2session?appid={0}&secret={1}&js_code={2}&grant_type=authorization_code",
                                 ApiConfig.AppId, ApiConfig.AppSecret, jsCode)
		    };
		    return await RestCommonJson<WxGetSessionCodeResp>(lHttpRequest);
		}
	}
}
